#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 2e5 + 7;
ll a[MAXN];
ll b[MAXN];
ll suf[MAXN];
void solve(){
	ll n,m;
	cin >> n >> m;
	for(int i = 1;i <= n;i++){
		cin >> a[i];
	}
	for(int i = 1;i <= n;i++){
		cin >> b[i];
	}
	ll sum = 0;
	for(int i = n;i > m;i--){
		sum += min(a[i],b[i]);
	}
	suf[m] = a[m];
	for(int i = m - 1;i >= 1;i--){
		suf[i] = suf[i + 1] - a[i + 1] + a[i] + b[i + 1]; 
	}
	int index = m;
	for(int i = m;i >= 1;i--){
		if(suf[i] < suf[index]){
			index = i;
		}
	}
	cout << suf[index] + sum << "\n";
}
int main(){
	ios::sync_with_stdio(false),cin.tie(0);
	int t = 1;
	cin >> t;
	while(t--) solve();
}